# UDP大小写转换客户端
import socket


def run_udp_client():
    # 创建UDP套接字
    client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

    # 获取用户输入
    message = input('请输入字符串: ')

    # 发送消息到服务器
    server_address = ('localhost', 12000)
    client_socket.sendto(message.encode(), server_address)

    # 接收服务器返回的消息
    modified_message, server = client_socket.recvfrom(2048)

    # 显示结果
    print(f"从服务器接收: {modified_message.decode()}")

    # 关闭套接字
    client_socket.close()


if __name__ == "__main__":
    run_udp_client()
